public class Test {
    //字符串拼接 （简易写法）
    public static void main1(String[] args) {
        String str1 = "hello ";
        String str2 = "world";
        System.out.println(str1+str2);
    }
    //字符串拼接
    public static void main2(String[] args) {
        String str1 = "hello";
        System.out.println("str1:" + str1);

        String str2 = "world";
        System.out.println("str2:" + str2);

        System.out.println("==========");

        String str3 = str1 + " " + str2;
        System.out.println("str3:" + str3);
    }


    //int转string
    public static void main3(String[] args) {
        int num = 10;
        //法1
        String str1 = num + "";
        //法2
        String str2 = String.valueOf(num);
        System.out.println(str1);
        System.out.println(str2);

        String str3 = String.valueOf(12345);
        System.out.println(str3);
    }

    //string转int /double
    public static void main4(String[] args) {
        String str1 = "100";
        int num1 = Integer.parseInt(str1);
        System.out.println(num1);
        System.out.println(num1+1);

        String str2 = "12.5";
        double num2 = Double.parseDouble(str2);
        System.out.println(num2);
    }


    //算术运算符
    public static void main5(String[] args) {
      /*  int a = 5;
        int b = 2;
        System.out.println(a/b);*/

        //符号取决于左操作数
      /*  System.out.println(10%3);
        System.out.println(-10%-3);
        System.out.println(-10%3);
        System.out.println(10%-3);*/
        //C语言%两边必须是整数，Java%两边可以是小数
//        System.out.println(10.5%5);

        //+=
     /*   int a = 5;
        a += 2;
        System.out.println(a);*/
        //注意：增量运算符在计算的时候，可以不进行强制类型转换
        double num1 = 12.5;
        int num2 = 10;
        num2 += num1; //不会报错
        System.out.println(num2); //输出22
        //num2 = num1 + num2;//编译报错，等号右边被提升为了double类型 【不兼容的类型: 从double转换到int可能会有损失】
    }


    //逻辑运算符
   /* 表达式&&表达式
      表达式||表达式
      ！表达式
      只能是布尔表达式  */
    public static void main6(String[] args) {
        int a = 10;
        //boolean flg = !10; //报错
        boolean flg1 = !true;
        boolean flg2 = !(a == 10);
        System.out.println(flg1);
        System.out.println(flg2);
    }
    //&& || 短路
    // &  |  不会短路
    public static void main(String[] args) {
        System.out.println(10 > 20 && 10 / 0 == 0); //false
        System.out.println(10 < 20 || 10 / 0 == 0); //true

        System.out.println(10 > 20 & 10 / 0 == 0); //程序抛出异常 因为除数不能为0
        System.out.println(10 < 20 | 10 / 0 == 0); //程序抛出异常
    }
}